<template>
  <div class="record">
    <div v-for="item in recordList" :key="item.id" class="record_item">
      <!-- 左侧区域 -->
      <div class="record_item_opinion" :style="item.fileids ? '' : 'width: 100%; border-right: none;'">
        <!-- 意见 -->
        <div class="record_item_opinion_text">{{ item.record }}</div>
        <!-- 人 / 时间 -->
        <div class="record_item_opinion_time">{{ item.fullname }} - {{ item.exectime }}</div>
      </div>
      <!-- 附件 -->
      <div v-if="item.fileids" class="record_item_file">
        <Upload :value="item.fileids" :disabled="true"/>
      </div>
    </div>
  </div>
</template>

<script>
import { queryList } from '@/api/correction/cre_work_record.js'
import storage from 'store'
import { APP_USER } from '@/store/mutation-types.js'
export default {
  props: {
    // 预警任务id
    workid: {
      type: String,
      require: true,
    },
  },
  data() {
    return {
      recordList: [], // 处置记录
      queryParam: {
        f_userid: undefined, // 记录人id
        pageNumber: 1,
        pageSize: 9999,
      },
      currentUser: storage.get(APP_USER), // 登录人信息
    }
  },
  created() {
    this.queryParam.f_userid = this.currentUser.userId
    this.queryParam.f_workid = this.workid
    this.queryList(this.queryParam)
  },
  methods: {
    // 父组件调用重新加载记录
    f_reload() {
      this.queryList(this.queryParam)
    },
    // 查询处置记录列表
    async queryList(queryParam) {
      const { data } = await queryList(queryParam)
      this.recordList = data.records || []
      this.$emit('f_recordList', this.recordList)
    },
  },
  components: {
    Upload: () => import('@/views/base/Upload.vue'),
  },
}
</script>

<style lang="scss" scoped>
@import '../../../assets/css/base/flex.scss';
.record {
  width: 100%;
  height: 100%;
  &_item {
    margin: 0 0 10px 0;
    border: 1px solid #ddd;
    border-radius: 10px;
    height: 12%;
    min-height: 10vh;
    @extend .space_between;

    &_file,
    &_opinion {
      height: 100%;
    }
    &_opinion {
      padding: 10px;
      width: 80%;
      border-right: 1px solid #ddd;
      &_text {
        height: 70%;
        overflow: auto;
        // border: 1px solid red;
      }
      &_time {
        height: 30%;
        // border: 1px solid red;
        // text-align: right;
      }
    }
    &_file {
      width: 20%;
      overflow: auto;
    }
  }
}
</style>
